package com.yhq.yhqproject.base.modules.board.web;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.yhq.yhqproject.base.common.web.ListByPageResp;
import com.yhq.yhqproject.base.modules.board.entity.AiTemplate;
import com.yhq.yhqproject.base.modules.board.entity.dto.CreatePromptReq;
import com.yhq.yhqproject.base.modules.board.entity.dto.ListTemplateReq;
import com.yhq.yhqproject.base.modules.board.entity.dto.TemplateAddDTO;
import com.yhq.yhqproject.base.modules.board.entity.dto.TemplateUpdateDTO;
import com.yhq.yhqproject.base.modules.board.service.AiTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Api(tags = "模板管理")
@ApiSort(100)
@RestController
@RequestMapping("/api/ai/template")
public class AiTemplateController {

    @Resource
    private AiTemplateService templateService;

    /**
     * 新增
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增")
    @PostMapping("/add")
    public String add(@RequestBody @Valid TemplateAddDTO dto) {
        return templateService.add(dto);
    }

    /**
     * 删除
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "删除")
    @GetMapping("/delete/{id}")
    public String delete(@PathVariable("id") String id) {
        return templateService.delete(id);
    }

    /**
     * 修改
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "修改")
    @PostMapping("/update")
    public String update(@RequestBody TemplateUpdateDTO dto) {
        return templateService.update(dto);
    }

    /**
     * 查看
     */
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "查看")
    @GetMapping("/query/{id}")
    public AiTemplate query(@PathVariable("id") String id) {
        return templateService.query(id);
    }

    /**
     * 枚举
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "枚举")
    @PostMapping("/list")
    public ListByPageResp<AiTemplate> list(@RequestBody ListTemplateReq req) {
        return templateService.list(req);
    }

    /**
     * 获得拼装prompt
     */
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "拼装prompt")
    @PostMapping("/create-prompt")
    public String createPrompt(@RequestBody CreatePromptReq req) {
        return templateService.createPrompt(req);
    }

}
